<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>{$current['title']}-{$Think.CONFIG.title}</title>
    <meta name="keywords" content="{$Think.CONFIG.keywords}" />
    <meta name="description" content="{$Think.CONFIG.description}" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <include file="Public/head" />
</head>
<body class="no-skin">
<include file="Public/header" />
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>
    <include file="Public/sidebar" />
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs" />
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set" />
                <!-- /section:settings.box -->

                <div class="row">
                    <div class="page-content">
						<div class="page-content-area">
							<div class="row">
								<div class="col-xs-12">
									<!-- PAGE CONTENT BEGINS -->

									<!--/span-->
									<!-- left menu ends -->
									<div style="margin-bottom:30px">
										<ul class="nav nav-tabs">
											<li class=""><a href="{:U('index')}">个人资料</a></li>
											<li class=""><a href="{:U('payment')}">收款信息</a></li>
											<li class="active"><a href="{:U('password')}">修改密码</a></li>
										</ul>
									</div>
									<form id="main-form" class="form-horizontal" onsubmit="return toVaild()">
										<div class="form-group">
											<label class="control-label col-sm-3">当前密码</label>
											<div class="col-sm-9">
												<input type="password" name="old_password" class="col-sm-5 col-xs-10">
												<p class="help-block help-block-error col-sm-7 col-xs-10 old_password_p
												"></p>
											</div>
										</div>
										<div class="form-group">
											<label class="control-label col-sm-3">新密码</label>
											<div class="col-sm-9">
												<input type="password" name="new_password" class="col-sm-5 col-xs-10" autocomplete="off" data-bind="value: new_password" data-val="true" data-val-required="请输入新密码" data-val-regex="新密码必须在 6 到 24 位之间" data-val-regex-pattern="^.{6,24}$">
												<p class="help-block help-block-error col-sm-7 col-xs-10 new_password_p"></p>
											</div>
										</div>
										<div class="form-group">
											<label class="control-label col-sm-3">新密码确认</label>
											<div class="col-sm-9">
												<input type="password" name="new_password_confirm" class="col-sm-5 col-xs-10">
												<p class="help-block help-block-error col-sm-7 col-xs-10 new_password_confirm_p"></p>
											</div>
										</div>
										<div class="form-group">
											<div class="col-sm-9 col-sm-offset-3">
												<button type="submit" class="btn btn-primary">确认修改</button>
											</div>
										</div>
									</form>
									<!-- PAGE CONTENT ENDS -->
								</div>
							</div><!-- /.row -->
						</div><!-- /.page-content-area -->
					</div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer" />
</div><!-- /.main-container -->
<include file="Public/footerjs" />
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript">
	function toVaild(){
		var old_password = $('input[name=old_password]').val();
		var new_password = $('input[name=new_password]').val();
		var new_password_confirm = $('input[name=new_password_confirm]').val();
		if(old_password==''){
			$('.old_password_p').html('请输入当前密码');
			return false;
		}
		if(new_password==''){
			$('.new_password_p').html('请输入新密码');
			return false;
		}
		if( 16<new_password.length && new_password.length < 6){
			$('.new_password_p').html('新密码必须在 6 到 16 位之间');
			return false;
		} 
		var reg = /^[A-Za-z0-9]{6,16}$/;  
		var r = new_password.match(reg);     
		if(r==null){
			$('.new_password_p').html('密码格式错误');   
		}  
		if(new_password!=new_password_confirm){
			$('.new_password_confirm_p').html('两次输入的密码不一致');
			return false;
		}
		$.post("{:U('password')}" , {ajax:1,old_password :old_password,new_password:new_password} , function(data){
			if(data.status ==  1){
				layer.alert(data.msg , function(){
						window.location.reload();
				});
			}else{
				layer.alert(data.msg);
			}
		},'json');
		
		return false;
		
	}
</script>
</body>
</html>